//
//  addpriceTableViewCell.m
//  BAOASystem
//
//  Created by michael on 2018/3/20.
//  Copyright © 2018年 czd. All rights reserved.
//

#import "addpriceTableViewCell.h"

@implementation addpriceTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
    _startfield = [[zhucetextfield alloc]init];
    _startfield.delegate = self;
           _startfield.keyboardType = UIKeyboardTypeNumberPad;
    _startfield.frame = CGRectZero;
[self.contentView addSubview:_startfield];
    _endfield = [[zhucetextfield alloc]init];
    _endfield.delegate = self;
               _endfield.keyboardType = UIKeyboardTypeNumberPad;

    _endfield.frame = CGRectZero;
[self.contentView addSubview:_endfield];

    _pricefield = [[zhucetextfield alloc]init];
    _pricefield.delegate = self;
               _pricefield.keyboardType = UIKeyboardTypeNumberPad;

    _pricefield.frame = CGRectZero;
[self.contentView addSubview:_pricefield];
}
return self;

}
//- (void)setDic:(NSDictionary *)dic{
//
// _dic = dic;
// 
//}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
   [_dic setValue:_startfield.text forKey:@"startNum"];
   [_dic setValue:_endfield.text forKey:@"endNum"];
     [_dic setValue:_pricefield.text forKey:@"price"];
}
- (BOOL)StringIsNullOrEmpty:(NSString *)str
{
    return (str == nil || [str isKindOfClass:[NSNull class]] || str.length == 0);
}
- (BOOL)isBlankString:(NSString *)aStr {
    if (!aStr) {
        return YES;
    }
    if ([aStr isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if (!aStr.length) {
        return YES;
    }
    NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
    NSString *trimmedStr = [aStr stringByTrimmingCharactersInSet:set];
    if (!trimmedStr.length) {
        return YES;
    }
    return NO;
}
- (void)layoutSubviews{
[super layoutSubviews];
NSString *startNum =[NSString stringWithFormat:@"%@",_dic[@"startNum"]];
NSString *endNum =[NSString stringWithFormat:@"%@",_dic[@"endNum"]];
NSString *price =[NSString stringWithFormat:@"%@",_dic[@"price"]];
if (![startNum isEqualToString:@"(null)"]) {
    _startfield.text = startNum ;

}if (![price isEqualToString:@"(null)"]) {
    _endfield.text = endNum ;

}if (![price isEqualToString:@"(null)"]) {
    _pricefield.text = price ;

}
//  _endfield.text =  [NSString stringWithFormat:@"%@",_dic[@"endNum"]];
////  _pricefield.text =  _dic[@"price"];
//
//    _pricefield.text =  [NSString stringWithFormat:@"%@",_dic[@"price"]];
_startfield.frame = CGRectMake(10, 5,( KScreenWidth-40)/3, 40);
_startfield.placeholder = NSLocalizedString(@"添加商品-购买数量开始段", nil);
_endfield.frame = CGRectMake(_startfield.right+10, 5,( KScreenWidth-40)/3, 40);
_endfield.placeholder = NSLocalizedString(@"添加商品-购买数量结束段", nil);
_pricefield.frame = CGRectMake(_endfield.right+10, 5,( KScreenWidth-40)/3, 40);
_pricefield.placeholder = NSLocalizedString(@"添加商品-商品单价(元)", nil);

}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

